package cn.zyl.demo.common.boot.beans;

import cn.zyl.demo.common.boot.abs.AbsResCode;

/**
 * ResBody类说明:响应实体类
 *
 * @author wsz
 * @version v1.0
 * @date 2020-07-31
 */
public class ResBody<T> {
    /** 响应码 */
    private int code;
    /** 响应信息 */
    private String msg;
    /** 响应数据 */
    private T data;

    public ResBody(AbsResCode res) { init(res, null); }
    public ResBody(AbsResCode res, T data) { init(res, data); }
    private void init(AbsResCode res, T data) {
        this.code = res.getCode();
        this.msg = res.getMsg();
        this.data = data;
    }

    public int getCode() { return code; }
    public void setCode(int code) { this.code = code; }
    public String getMsg() { return msg; }
    public void setMsg(String msg) { this.msg = msg; }
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }
    @Override
    public String toString() {
        return "{ code=" + code + ", msg='" + msg + "', data=" + data + '}';
    }
}
